package cn.wetcland.urban.framework.service.impl;

import cn.dev33.satoken.stp.StpUtil;
import cn.wetcland.urban.common.MyAssert;
import cn.wetcland.urban.common.utils.CopyObjectUtil;
import cn.wetcland.urban.framework.mapper.UtNoticeMapper;
import cn.wetcland.urban.framework.service.UtNoticeService;
import cn.wetcland.urban.framework.utils.StpDriverUtil;
import cn.wetcland.urban.framework.vo.NoticeListItemVO;
import cn.wetcland.urban.generator.domain.UtNotice;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Wetcland
* @description 针对表【ut_notice】的数据库操作Service实现
* @createDate 2024-01-21 09:51:59
*/
@Service
public class UtNoticeServiceImpl extends ServiceImpl<UtNoticeMapper, UtNotice> implements UtNoticeService {

    @Resource
    public UtNoticeMapper noticeMapper;

    @Override
    public List<NoticeListItemVO> getConsumerNoticeList() {
        return noticeMapper.selectConsumerNoticeList();
    }

    @Override
    public List<NoticeListItemVO> getDriverNoticeList() {
        return noticeMapper.selectDriverNoticeList();
    }

    @Override
    public NoticeListItemVO getNoticeDetails(Long noticeId) {
        MyAssert.isTrue(StpUtil.isLogin() || StpDriverUtil.isLogin(), "未登录无法查看");
        UtNotice utNotice = noticeMapper.selectById(noticeId);
        NoticeListItemVO noticeListItemVO = new NoticeListItemVO();
        CopyObjectUtil.copyPropertiesIgnoreNull(utNotice, noticeListItemVO);
        return noticeListItemVO;
    }
}




